package com.leetcode.algorithm.y22.m09.w3;

import com.leetcode.algorithm.common.TreeNode;

/**
 * 814. 二叉树剪枝
 * 
 * https://leetcode.cn/problems/binary-tree-pruning/
 * 
 * @author jie.deng
 *
 */
class Question0814Solution01 {

	public TreeNode pruneTree(TreeNode root) {
		// DFS 后序遍历
		if (root == null) {
			return null;
		}
		root.left = pruneTree(root.left);
		root.right = pruneTree(root.right);
		if (root.left == null && root.right == null && root.val == 0) {
			return null;
		}
		return root;
	}

}